package com.yhgarden.bbs.model.interceptor;

import com.yhgarden.bbs.model.enums.StatusCode;
import com.yhgarden.bbs.model.exception.YhbbsException;
import com.yhgarden.bbs.model.response.BaseResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class YhbbsExceptionHandler {
    //自定义异常返回对应编码
    @ExceptionHandler(YhbbsException.class)
    @ResponseBody
    public BaseResponse handlerYhbbsException(YhbbsException yhbbsException) {
        return new BaseResponse(yhbbsException.getStatus());
    }

}
